package Databases

import (
	"fmt"
	"gin/study_1/utils"
	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/mysql"
)

var DB *gorm.DB

var Config utils.GlobalConfig

func init() {

	var err error
	// 从配置文件中获取数据库等信息
	DB, err = gorm.Open(utils.TheGlobalconfig.Database.Types, utils.TheGlobalconfig.Database.Local)
	if err != nil {
		fmt.Printf("mysql connect error %v", err)
	}
	if DB.Error != nil {
		fmt.Printf("database error %v", DB.Error)
	}
	fmt.Println("初始化数据库成功")



}